SV_SYNTH_SOURCES=system/System.sv
VERILOG_SYNTH_SOURCE=system/System.v

TOP_MODULE_RESOURCE_CHECK=SystemResourceCheck
TOP_MODULE_DEMO=SystemDemo
CONSTRAINTS=../common/constraints/ulx3s.lpf

ZIP_SOURCES=DatapathPipelinedCache.sv ../hw2b-cla/cla.sv ../hw4-multicycle/DividerUnsignedPipelined.sv
ZIP_FILE=cache.zip

include ../common/make/fpga.mk


ifndef CLOCK_FREQUENCY
CLOCK_FREQUENCY=30
endif

CLOCK_GEN_NAME=MyClockGen
CLOCK_GEN_FILE=$(CLOCK_GEN_NAME).v

clock-gen:
	mkdir -p $(BACKEND_OUTPUT_DIR)
	ecppll --internal_feedback --clkin_name input_clk_25MHz --clkin 25 --clkout0_name clk_125MHz --clkout0 125 --clkout1_name clk_25MHz --clkout1 25 --clkout2_name clk_proc --clkout2 $(CLOCK_FREQUENCY) -n $(CLOCK_GEN_NAME) -f .tmp-clk-gen.v > $(BACKEND_OUTPUT_DIR)/clock_generation_report.txt
	@echo 'check that clocks have the proper frequencies'
	grep 'clkout0 frequency: 125 MHz' $(BACKEND_OUTPUT_DIR)/clock_generation_report.txt
	grep 'clkout1 frequency: 25 MHz' $(BACKEND_OUTPUT_DIR)/clock_generation_report.txt
	@echo '//' > $(CLOCK_GEN_FILE) # overwrite existing file
	@echo '// DO NOT EDIT: This file was auto-generated by the ecppll program' >> $(CLOCK_GEN_FILE)
	@echo '//' >> $(CLOCK_GEN_FILE)
	@echo '' >> $(CLOCK_GEN_FILE)
	@echo '`timescale 1ns / 1ns' >> $(CLOCK_GEN_FILE)
	@echo '' >> $(CLOCK_GEN_FILE)
	@cat .tmp-clk-gen.v >> $(CLOCK_GEN_FILE)

